//
//  CustomButton.m
//  gdemm
//
//  Created by 乔明超 on 16/9/27.
//  Copyright © 2016年 Goldencis. All rights reserved.
//

#import "CustomButton.h"
#import "Utils.h"
#import "Masonry.h"
@interface CustomButton()

@end
@implementation CustomButton

- (void)layoutSubviews{
    [super layoutSubviews];
    
    [self setTitleColor:[Utils colorWithKey:@"crushFontColor"] forState:UIControlStateNormal];
    
    if ([DeviceTypeJudge isPadDeviceType]) {
        self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);
        self.imageView.size = CGSizeMake(self.imageView.image.size.width, self.imageView.image.size.height);
        self.imageView.centerX = self.width / 2;
        self.imageView.y = 0;
        self.titleLabel.frame = CGRectMake(0, CGRectGetMaxY(self.imageView.frame) + 10, self.imageView.image.size.width + 10 , 30);
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont boldSystemFontOfSize:14];
        self.size = CGSizeMake(self.titleLabel.width, self.imageView.height + self.titleLabel.height);
    }else{
    
        self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width-10, self.imageView.image.size.height-10);
        self.imageView.size = CGSizeMake(self.imageView.image.size.width, self.imageView.image.size.height);
        self.imageView.centerX = self.width / 2;
        self.imageView.y = 0;
        self.titleLabel.frame = CGRectMake(0, CGRectGetMaxY(self.imageView.frame) + 5, self.imageView.image.size.width + 10 , 25);
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont boldSystemFontOfSize:12];
        self.size = CGSizeMake(self.titleLabel.width, self.imageView.height + self.titleLabel.height);
    }
}


@end
